﻿using System;
using Tao.OpenGl;

namespace Aeon.Framework.Objects.Models
{

/// <summary>
/// Loadable model objects wrapper class.
/// 
/// </summary>
public class Model<T> : ObjectBase, IModel where T : IParserModel, new()
    {
    // --- Attributes:
    
    protected IModelAdapter model;     // Model object.

    // --- Constructor:

    public Model(String key, Position origin, Orientation angle, AeonMaterial material, String file)
        : base(key,origin,angle,material)
        {        
        model = ParserModel<T>.Instance.Parse(file);
        }

    // --- Public Methods:

    public override void Draw()
        {
        Gl.glTranslated(origin.xPos,origin.yPos,origin.zPos);
        Gl.glRotated(angle.xAng,1,0,0);
        Gl.glRotated(angle.yAng,0,1,0);
        Gl.glRotated(angle.zAng,0,0,1);

        Gl.glPushMatrix();
        model.Draw();        
        Gl.glPopMatrix();
        }

    }


}
